package com.bluefox.system;

/**
 * @Author : 清风冷影
 * @Description:
 * @Date : 2021/8/17  13:36
 */
public class test1 {
    public static void main(String[] args) {
        String type="2";
        String[] yearOrMonth = "2021-06".split("-");
        int year = Integer.valueOf(yearOrMonth[0]);
        int month = Integer.valueOf(yearOrMonth[1]);

        String where = " WHERE DATEPART(YEAR, dwell_time)='" + year + "' AND DATEPART(MONTH, dwell_time)='" + month + "' ";

        if ("1".equals(type)) {
            where += " AND IS_PUBLISH=1 ";
        } else {
            where += " AND IS_GKDM=1 ";
        }

        // 根据月份时候显示断流信息.
//			int dlvalue = 0;
//			int sumvalue = 0;
//			String remark = "";
//			int flag = 10;



        StringBuffer sb = new StringBuffer();
        sb.append("SELECT * FROM (SELECT " +
                "	s.CITYNAME," +
                "	s.union_C0007_PNAME, " +
                "	s.C0028_RNAME, " +
                "	s.C0007_PNAME, " +
                "	s.dwell_time, " +
                "	s.water_temperature, " +
                "	s.pH,s.cyanide, " +
                "	s.TDS, " +
                "	s.DO, " +
                "	s.COD, " +
                "	s.CODMn, " +
                "	s.BOD, " +
                "	s.NH3_N, " +
                "	s.OIL, " +
                "	s.VP, " +
                "	s.Hg, " +
                "	s.Pb, " +
                "	s.TN, " +
                "	s.TP, " +
                "	s.Cu, " +
                "	s.Zn, " +
                "	s.APF, " +
                "	s.Se, " +
                "	s.Arsenic, " +
                "	s.Cd, " +
                "	s.Cr6, " +
                "	s.AOS, " +
                "	s.COS, " +
                "	s.TVC, " +
                "	s.ION, " +
                "	s.chlorid, " +
                "	s.nitrate, " +
                "	s.Fe, " +
                "	s.Mn, " +
                "	s.water_line, " +
                "	s.C0035_function_WQ, " +
                "	s.remark,s.oos " +
                "FROM " +
                "	t_heliu_report s" + where +
                "UNION ALL " +
                "	SELECT " +
                "		t.CITYNAME, " +
                "	t.union_C0007_PNAME, " +
                "	t.C0028_RNAME, " +
                "	t.C0007_PNAME, " +
                "	t.dwell_time, " +
                "	t.water_temperature, " +
                "	t.pH,t.CYN, " +
                "	t.TDS, " +
                "	t.DO, " +
                "	t.COD, " +
                "	t.CODMn, " +
                "	t.BOD, " +
                "	t.NH3_N, " +
                "	t.OIL, " +
                "	t.VP, " +
                "	t.Hg, " +
                "	t.Pb, " +
                "	t.TN, " +
                "	t.TP, " +
                "	t.Cu, " +
                "	t.Zn, " +
                "	t.APF, " +
                "	t.Se, " +
                "	t.Arsenic, " +
                "	t.Cd, " +
                "	t.Cr6, " +
                "	t.AOS, " +
                "	t.COS, " +
                "	t.TVC, " +
                "	t.ION, " +
                "	t.chlorid, " +
                "	t.nitrate, " +
                "	t.Fe, " +
                "	t.Mn, " +
                "	t.water_line, " +
                "	t.C0035_function_WQ, " +
                "	t.remark,t.oos " +
                "	FROM " +
                "		t_huku_report t " + where +
                ") DM left join GKDM G ON DM.C0007_PNAME = G.NAME " +
                "" + "LEFT JOIN T_STATION t ON t.C0003_STNAME = SUBSTRING( G.CITY, 1, 2)");
        System.out.println(sb.toString());
    }
}
